<?php
include ('../../__global.php');

class _3rd_bind_controller extends ml_controller {
    public function init()
    {
        $this->set_access(self::ACCESS_SELF , self::NOACCESS_REDIRECT );
    }
    public function initParam() {
    
    }
    public function checkParam() {
    
    }
    public function main() {
        if(!$this->check_permission(ML_PERMISSION_LOGIN_ONLY)) {
            $this->redirect(ML_PAGE_LOGIN);
        }
        $data = array (
                    'sina' => '', 
                    'tencent' => '', 
                    'renren' => '' );
        $_3rd_bind = NULL;
        ml_tool_actionlog::add_other_action($this->__visitor['uid'] , ML_SINAACTCODE_VIEW_SET_3RD);
        
        
        $DB_3rd = new ml_model_db3rdService ();
        if ($DB_3rd->get3rdServiceType ( $this->__visitor['uid'], &$_3rd_bind )) {
            if (! empty ( $_3rd_bind )) {
                foreach ( $_3rd_bind as $temp ) {
                    if ($temp['service_id'] == 1)
                        $data ['sina'] = $temp ['3rd_id'];
                    elseif($temp['service_id']==2)
                        $data ['tencent'] = $temp ['3rd_id'];
                    elseif($temp['service_id']==3)
                        $data ['renren'] = $temp ['3rd_id'];
                }
            }
            $this->set_scope_var('$pageid' , '3rd_bind');
            $this->page_output ( 'user::3rd_bind', $data );
        } else {
            // 服务器繁忙
            //todo
        }
        die ( '' );
    
    }
}
new _3rd_bind_controller ();